package us.mooresr.geartrack.server.handler;

import us.mooresr.geartrack.server.DAO;
import us.mooresr.geartrack.shared.action.DeleteLoanAction;
import us.mooresr.geartrack.shared.action.DeleteLoanResult;

import com.gwtplatform.dispatch.server.ExecutionContext;
import com.gwtplatform.dispatch.server.actionhandler.ActionHandler;
import com.gwtplatform.dispatch.shared.ActionException;

public class DeleteLoanActionHandler implements ActionHandler<DeleteLoanAction, DeleteLoanResult>{

	@Override
	public DeleteLoanResult execute(DeleteLoanAction action, ExecutionContext arg1)
			throws ActionException {
		DAO dao = new DAO();
		
		dao.ofy().delete(action.getLoanIn());
		
		return new DeleteLoanResult(action.getLoanIn());
	}

	@Override
	public Class<DeleteLoanAction> getActionType() {
		return DeleteLoanAction.class;
	}

	@Override
	public void undo(DeleteLoanAction arg0, DeleteLoanResult arg1,
			ExecutionContext arg2) throws ActionException {
		// TODO Auto-generated method stub
		
	}

}
